Skip to content

fix(msggateway): avoid closed channel panic in super group push - #3767

Open
buvidk1234 wants to merge 1 commit into
openimsdk:mainfrom
buvidk1234:fix/supergroup-push-channel-close
Open

fix(msggateway): avoid closed channel panic in super group push#3767
buvidk1234 wants to merge 1 commit into
openimsdk:mainfrom
buvidk1234:fix/supergroup-push-channel-close

Conversation

@buvidk1234

Copy link
Copy Markdown
Contributor

🅰 Please add the issue ID after "Fixes #"

Fixes #

Summary

Fix a panic risk in SuperGroupOnlineBatchPushOneMsg when queue enqueue fails.

Problem

SuperGroupOnlineBatchPushOneMsg uses a result channel to collect per-user push results and closes the channel when all pending users are handled.

In the PushCtx error branch, the previous code decremented the pending counter and could close the result channel before sending the fallback result. If the failed enqueue was the last pending item, the following send would panic:

panic: send on closed channel

This can happen on abnormal paths such as request context cancellation while the in-memory queue is unable to accept another task, or when the queue has already stopped.

Changes

  • Centralized result sending and completion accounting in pushResult.
  • Ensured both success and PushCtx error paths send the user result before decrementing the pending counter.
  • Kept the last completed sender responsible for closing the result channel.

@pull-request-size pull-request-size Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant